//
//  RONetworkMngTool.swift
//  yuejian
//
//  Created by gyy on 2017/9/26.
//  Copyright © 2017年 gyy. All rights reserved.
//

import UIKit
var userId : NSString!
let single = RONetworkMngTool()
class RONetworkMngTool: NSObject {
    
    class func sharedNetWorkMngTool()-> RONetworkMngTool {
        return single
    }
    //获取julebu信息
    func RONetwork_GetclubList(_ view: UIView, block: @escaping (_ clubList: NSArray) -> Void)  {
         MBProgressHUD.showAdded(to: view, animated: true)
        let afManager = AFHTTPRequestOperationManager()
        afManager.get("http://172.24.10.175/workout/api.php/lists/mod/club",parameters: nil, success: {(Operation:AFHTTPRequestOperation?, responseObjct:Any?) in
            //    MBProgressHUD.hide(for: view, animated: true)
            //  print(responseObjct)
            //  MBProgressHUD.showAdded(to: view, animated: true)
            let clubArray = responseObjct as! NSArray
            let clubMutableArray: NSMutableArray = NSMutableArray()
            for aclubDict in clubArray{
                let clubDict = aclubDict as! NSDictionary
                let club: ROclubModel = ROclubModel.clubModelWithDict(clubDict)
                clubMutableArray.add(club)
            }
            block(clubMutableArray)
            
        }, failure:{ (Operation: AFHTTPRequestOperation?, error:Error?) in
            MBProgressHUD.hide(for: view, animated: true)
            MBProgressHUD.showDelayHUDToView(view, message: "网络故障，请重试")
        })
//
  }

}
